package com.samphanie.dries.model;

import android.text.TextUtils;

import androidx.annotation.Nullable;
import androidx.databinding.BaseObservable;
import androidx.databinding.Bindable;

import java.io.Serializable;

public class Feed extends BaseObservable implements Serializable {

    public static final int TYPE_IMAGE_TEXT = 1;//图文
    public static final int TYPE_VIDEO = 2;//视频
    /**
     * id : 364
     * itemId : 6739143063064549000
     * itemType : 2
     * createTime : 1569079017
     * duration : 299.435
     * feeds_text : 当中国地图出来那一幕，我眼泪都出来了！
     * 太震撼了！
     * authorId : 3223400206308231
     * activityIcon : null
     * activityText : null
     * width : 640
     * height : 368
     * url : https://pipijoke.oss-cn-hangzhou.aliyuncs.com/6739143063064549643.mp4
     * cover : https://p3-dy.byteimg.com/img/mosaic-legacy/2d676000e36289f35f70c~640x368_q80.webp
     */

    private int id;
    private long itemId;
    private int itemType;
    private long createTime;
    private double duration;
    private String feeds_text;
    private long authorId;
    private String activityIcon;
    private String activityText;
    private int width;
    private int height;
    private String url;
    private String cover;

    private User author;
    private Comment topComment;
    private Ugc ugc;

    @Bindable
    public Ugc getUgc() {
        if (ugc == null) {
            ugc = new Ugc();
        }
        return ugc;
    }

    @Bindable
    public User getAuthor() {
        if (author == null) {
            author = new User();
        }
        return author;
    }

    @Override
    public boolean equals(@Nullable Object obj) {
        if (!(obj instanceof Feed)) {
            return false;
        }

        Feed newFeed = (Feed) obj;
        return id == newFeed.getId()
                && itemId == newFeed.getItemId()
                && itemType == newFeed.getItemType()
                && createTime == newFeed.getCreateTime()
                && duration == newFeed.getDuration()
                && TextUtils.equals(feeds_text, newFeed.getFeeds_text())
                && authorId == newFeed.getAuthorId()
                && TextUtils.equals(activityIcon, newFeed.getActivityIcon())
                && TextUtils.equals(activityText, newFeed.getActivityText())
                && width == newFeed.getWidth()
                && height == newFeed.getHeight()
                && TextUtils.equals(url, newFeed.getUrl())
                && TextUtils.equals(cover, newFeed.getCover())
                && (author != null && author.equals(newFeed.getAuthor()))
                && (topComment != null && topComment.equals(newFeed.getTopComment()))
                && (ugc != null && ugc.equals(newFeed.getUgc()));
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public long getItemId() {
        return itemId;
    }

    public void setItemId(long itemId) {
        this.itemId = itemId;
    }

    public int getItemType() {
        return itemType;
    }

    public void setItemType(int itemType) {
        this.itemType = itemType;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public double getDuration() {
        return duration;
    }

    public void setDuration(double duration) {
        this.duration = duration;
    }

    public String getFeeds_text() {
        return feeds_text;
    }

    public void setFeeds_text(String feeds_text) {
        this.feeds_text = feeds_text;
    }

    public long getAuthorId() {
        return authorId;
    }

    public void setAuthorId(long authorId) {
        this.authorId = authorId;
    }

    public String getActivityIcon() {
        return activityIcon;
    }

    public void setActivityIcon(String activityIcon) {
        this.activityIcon = activityIcon;
    }

    public String getActivityText() {
        return activityText;
    }

    public void setActivityText(String activityText) {
        this.activityText = activityText;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getCover() {
        return cover;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public void setAuthor(User author) {
        this.author = author;
    }

    public Comment getTopComment() {
        return topComment;
    }

    public void setTopComment(Comment topComment) {
        this.topComment = topComment;
    }

    public void setUgc(Ugc ugc) {
        this.ugc = ugc;
    }
}
